<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="/lib/jquery-3.4.1/jquery-3.4.1.min.js" charset="utf-8"></script>
    <script src="/js/echarts.min.js" charset="utf-8"></script>
</head>

<body>
    <div id="main" style="width: 600px; height:400px;"></div>

    <script>
        var chartDom = document.getElementById('main');
        var myChart = echarts.init(chartDom);
        var option;


        $.ajax({
            url: "http://localhost:8080/floorTable/barTable",
            data: {},
            success: function (result) {
                var brandList = [];
                var brandCount = [];
                var arr = result.data.brandBar;
                for (var i = 0; i < arr.length; i++) {
                    brandList.push(arr[i].brand);
                    brandCount.push(arr[i].count);
                }

                option = {
                    title:{
                        text:'监控品牌比例柱状图'
                    },
                    tooltip: {
                        trigger: 'axis',
                        axisPointer: {
                            type: 'shadow'
                        }
                    },
                    xAxis: {
                        type: 'category',
                        data: brandList
                    },
                    yAxis: {
                        type: 'value'
                    },
                    series: [
                        {
                            data: brandCount,
                            type: 'bar',
                            showBackground: true,
                            backgroundStyle: {
                                color: 'rgba(180, 180, 180, 0.2)'
                            }
                        }
                    ]
                };

                myChart.setOption(option);
            },
            dataType: "json"
        })


    </script>
</body>

</html>